package com.ruoyi.web.controller.obtain;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.obtain.domain.EduTeacherUser;
import com.ruoyi.obtain.service.IEduTeacherUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 身份绑定Controller
 * 
 * @author ruoyi
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/obtain/teacher_user")
public class EduTeacherUserController extends BaseController
{
    @Autowired
    private IEduTeacherUserService eduTeacherUserService;

    /**
     * 查询身份绑定列表
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduTeacherUser eduTeacherUser)
    {
        startPage();
        List<EduTeacherUser> list = eduTeacherUserService.selectEduTeacherUserList(eduTeacherUser);
        return getDataTable(list);
    }

    /**
     * 导出身份绑定列表
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:export')")
    @Log(title = "身份绑定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduTeacherUser eduTeacherUser)
    {
        List<EduTeacherUser> list = eduTeacherUserService.selectEduTeacherUserList(eduTeacherUser);
        ExcelUtil<EduTeacherUser> util = new ExcelUtil<EduTeacherUser>(EduTeacherUser.class);
        util.exportExcel(response, list, "身份绑定数据");
    }

    /**
     * 获取身份绑定详细信息
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eduTeacherUserService.selectEduTeacherUserById(id));
    }

    /**
     * 新增身份绑定
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:add')")
    @Log(title = "身份绑定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduTeacherUser eduTeacherUser)
    {
        return toAjax(eduTeacherUserService.insertEduTeacherUser(eduTeacherUser));
    }

    /**
     * 修改身份绑定
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:edit')")
    @Log(title = "身份绑定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduTeacherUser eduTeacherUser)
    {
        return toAjax(eduTeacherUserService.updateEduTeacherUser(eduTeacherUser));
    }

    /**
     * 删除身份绑定
     */
    @PreAuthorize("@ss.hasPermi('obtain:teacher_user:remove')")
    @Log(title = "身份绑定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eduTeacherUserService.deleteEduTeacherUserByIds(ids));
    }
}
